<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
	<title>TravelDream Home</title>
	<h:outputStylesheet library="TdTheme" name="css/style.css"/> 	
</h:head>
<h:body>	
	<h:form>      
	    <p:menubar>  
	        <p:submenu label="Inserisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="crea_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="crea_escursione.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="crea_volo.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Gestisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="cerca_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="cerca_escursioni.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="cerca_voli.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Pacchetti Preconfigurati" icon="ui-icon-document">  
	            <p:menuitem value="Crea" url="crea_pp.xhtml?faces-redirect.xhtml"/>  
	            <p:menuitem value="Gestisci" url="gestione_pp.xhtml?faces-redirect=true" />  
	        </p:submenu>    
	  
	        <f:facet name="options">  
	            <p:commandButton value="Logout" icon="ui-icon-extlink" action="#{loginManagedBean.logout()}"/>  
	        </f:facet>  
	    </p:menubar>  
  	</h:form>  
  	<h:form>
	<p:messages id="messaggio" showDetail="true" autoUpdate="true" closable="true" /> 
	</h:form>
	<h:panelGrid columns="1" styleClass="userTopBar">
		<p:panel id="panel">
			<h:form id="search_form">
				<h:panelGrid columns = "5">
					<h:outputLabel value="Nome escursione:" />
					<p:inputText value="#{escursioneManagedBean.nome}" id="nameInput"/>
					<h:outputLabel value="Citta di fruizione:" />
					<p:inputText value="#{escursioneManagedBean.luogoFruizione}" id="cittaInput"/>
					<br/>
					<p:outputLabel>Escludi pacchetti non in vendita: </p:outputLabel>
					<p:selectBooleanCheckbox value="#{escursioneManagedBean.escludiNonInVendita}"/>
					<p:commandButton value="Cerca" action="#{escursioneManagedBean.searchEscursione()}"/>
				</h:panelGrid>
				<p:dataTable id="searchOutput" var="n" value="#{escursioneManagedBean.listaEscursioni}">
  						<p:column headerText="ID">
                    		<h:outputText value="#{n.id}"/>
                		</p:column>
						
						<p:column headerText="Nome">
		                    <h:outputText value="#{n.nome}"/>
		                </p:column>
						
		                <p:column headerText="Citta">
		                    <h:outputText value="#{n.luogo_Fruizione}"/>
		                </p:column>
		
		                <p:column headerText="Prezzo">
		                    <h:outputText value="#{n.prezzo}"/>
		                </p:column>

       			        <p:column headerText="Stato" rendered="#{!escursioneManagedBean.escludiNonInVendita}">
		                	<h:outputText value="In vendita" rendered="#{n.inVendita}" style="color:#00F;"/>
		                	<h:outputText value="Non in vendita" rendered="#{!n.inVendita}" style="color:#F00;" />
		                </p:column>
       			        
		                <p:column>
		                	<p:commandButton value="Modifica" action="#{modificaEscursioneManagedBean.parametriEscursione(n)}"/>
							<p:commandButton value="Elimina" action="#{escursioneManagedBean.eliminaEscursione(n)}"/>
							<p:commandButton value="Rimuovi dalla vendita" action="#{escursioneManagedBean.cambioStatoVendita(n)}" rendered="#{escursioneManagedBean.isInVendita(n)}"/>
							<p:commandButton value="Metti in vendita" action="#{escursioneManagedBean.cambioStatoVendita(n)}" rendered="#{!escursioneManagedBean.isInVendita(n)}"/>
		                </p:column>
                </p:dataTable>	
			</h:form>
		</p:panel>
	</h:panelGrid>
</h:body>
</html>